﻿using DAL;
using FubiManger.Controls;
using Model;
using Smobiler.Core;
using Smobiler.Core.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Script.Serialization;
using FubiManger.UI;

namespace FubiManger.Logistics
{
    partial class LogOrdinfoForm : Smobiler.Core.Controls.MobileForm
    {
        public LogOrdinfoForm() : base()
        {
            //This call is required by the SmobilerForm.
            InitializeComponent();
        }
        /// <summary>
        /// 商户号
        /// </summary>
        public string merchantid { get; set; }        
        /// <summary>
        /// 订单号
        /// </summary>
        public string ordsn { get; set; }
        ms_order order = new ms_order();
        private void panclose_Press(object sender, EventArgs e)
        {
            this.Close();
        }

        private void LogOrdinfoForm_Load(object sender, EventArgs e)
        {
            order = orderDal.Querybysn(ordsn);
            if (order.status == "3")
            {
                panlog.Height = 0;
                panall.Location = new System.Drawing.Point(10, 10);
                pbtm.Height = 40;
            }
            else if (order.status == "5")
            {
                panlog.Height = 74;
                panall.Location = new System.Drawing.Point(10, 86);
                pbtm.Height = 0;
                lblnumber.Text ="运单号："+ order.courier_number;//运单号
                lblexpress_name.Text = "快递公司："+order.express_name;//快递公司
            }
            JavaScriptSerializer js = new JavaScriptSerializer();   //实例化一个能够序列化数据的类
            List<Gdpro> prolist = js.Deserialize<List<Gdpro>>(order.goods_info);
            panpros.Height = prolist.Count * 44;
            panord.Height = panpros.Height + 30;
            panbtm.Location = new System.Drawing.Point(0, panord.Height + 100);
            panall.Height = panord.Height + pantp.Height + 40;
            for (int i = 0; i < prolist.Count; i++)
            {
                ordergpcontrol con = new ordergpcontrol();
                con.proname = prolist[i].proname;
                con.cout = "x " + prolist[i].count;
                con.price = "￥ " + prolist[i].price;
                panpros.Controls.Add(con);
            }
            lblordsn.Text = order.order_sn;//订单编号
            lbltime.Text = Convert.ToDateTime(order.add_time).ToString("yyyy-MM-dd HH:mm:ss");
            lblprice.Text = "￥" + order.pay_price;//实付金额
        }
        /// <summary>
        /// 发物流
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnlog_Press(object sender, EventArgs e)
        {
            LogisticsForm frm = new LogisticsForm();
            frm.ordsn = order.order_sn;//订单号
            this.Form.Show(frm, true);
        }
    }
}